<?php
include "../config/koneksi.php";
include "../class/toko.php";

if (ISSET($_GET["id_toko"])){
	$id_toko=$_GET["id_toko"];
	$toko_dao = new Toko_Dao();
	$toko=$toko_dao->get($id_toko);
}
if (ISSET($_POST["edit"]) && ISSET($_POST["Submit42"])&& $_POST['nama_toko']!="" && 
$_POST['alamat']!="" && $_POST['kota']!="" && $_POST['kodepos']!="" && $_POST['telp']!="" && $_POST['email']!="" && $_POST['nama_bank']!="" && $_POST['cabang']!=""
&& $_POST['atas_nama']!="" && $_POST['rek']!="" && $_POST['deskripsi_toko']!="" ){
	$toko_dao = new Toko_Dao();
	$toko= new Toko();
	$toko->id_toko = $_POST['id_toko'];
	$toko->nama_toko = $_POST['nama_toko'];
	$toko->alamat = $_POST['alamat'];
	$toko->kota = $_POST['kota'];
	$toko->kodepos = $_POST['kodepos'];
	$toko->telp = $_POST['telp'];
	$toko->email = $_POST['email'];
	$toko->nama_bank = $_POST['nama_bank'];
	$toko->cabang = $_POST['cabang'];
	$toko->atas_nama = $_POST['atas_nama'];
	$toko->rek = $_POST['rek'];
	$toko->deskripsi_toko = $_POST['deskripsi_toko'];
	$toko_dao->edit($toko);
	header("Location:index.php?menu=view_toko");
}
?>
<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0">
  <tr >
    <td height="30"> 
      <div align="left"><font size="3" face="tahoma">Edit Toko</font><hr color=#CCCCFF></div></td>
    </tr>
  </table>
<form name="edit" method="post" action="edit_toko.php" enctype="multipart/form-data">
<input type="hidden" name="edit">
<input type="hidden" name="id_toko" value="<?php echo $toko->id_toko;?>">

  <table width="60%" border="0" align="center" bordercolor="#FF9900" bgcolor="#FFFFFF">
    <tr bordercolor="#FFFFFF"> 
      <td><font size="2" face="tahoma">Nama Toko</font></td>
      <td valign=top>:</td>
      <td valign=top> <input name="nama_toko" type="text" id="nama_toko" value='<?php echo $toko->nama_toko;?>'></td>
    </tr>
	<tr bordercolor="#FFFFFF"> 
      <td><font size="2" face="tahoma">Alamat</font></td>
      <td valign=top>:</td>
      <td valign=top> <input name="alamat" type="text" id="alamat" value='<?php echo $toko->alamat;?>'></td>
    </tr>
	<tr bordercolor="#FFFFFF"> 
      <td><font size="2" face="tahoma">Kota</font></td>
      <td valign=top>:</td>
      <td valign=top> <input name="kota" type="text" id="kota" value='<?php echo $toko->kota;?>'></td>
    </tr>
	    <tr bordercolor="#FFFFFF"> 
      <td><font size="2" face="tahoma">Kode Pos</font></td>
      <td valign=top>:</td>
      <td valign=top> <input name="kodepos" type="text" id="kodepos" value='<?php echo $toko->kodepos?>'></td>
    </tr>
	    <tr bordercolor="#FFFFFF"> 
      <td><font size="2" face="tahoma">Telepon</font></td>
      <td valign=top>:</td>
      <td valign=top> <input name="telp" type="text" id="telp" value='<?php echo $toko->telp?>'></td>
    </tr>
	<tr bordercolor="#FFFFFF"> 
      <td><font size="2" face="tahoma">Email</font></td>
      <td valign=top>:</td>
      <td valign=top> <input name="email" type="text" id="email" value='<?php echo $toko->email?>'></td>
    </tr>
	<tr bordercolor="#FFFFFF"> 
      <td><font size="2" face="tahoma">Deskripsi Toko</font></td>
      <td valign=center>:</td>
      <td valign=top> <textarea cols=30 rows=5 name="deskripsi_toko"><?php echo $toko->deskripsi_toko?></textarea></td>
    </tr>
	<tr>
	<td colspan=2 align=center></td><td><font face=tahoma size=2><br><br>Informasi Rekening Anda</font></td>
	</tr>
	<tr bordercolor="#FFFFFF"> 
      <td><font size="2" face="tahoma">Rekening Bank</font></td>
      <td valign=top>:</td>
      <td valign=top> <input name="nama_bank" type="text" id="nama_bank" value='<?php echo $toko->nama_bank?>'></td>
    </tr>
	<tr bordercolor="#FFFFFF"> 
      <td><font size="2" face="tahoma">Cabang</font></td>
      <td valign=top>:</td>
      <td valign=top> <input name="cabang" type="text" id="cabang" value='<?php echo $toko->cabang?>'></td>
    </tr>
	<tr bordercolor="#FFFFFF"> 
      <td><font size="2" face="tahoma">Atas Nama</font></td>
      <td valign=top>:</td>
      <td valign=top> <input name="atas_nama" type="text" id="atas_nama" value='<?php echo $toko->atas_nama?>'></td>
    </tr>
	<tr bordercolor="#FFFFFF"> 
      <td><font size="2" face="tahoma">Nomor Rekening</font></td>
      <td valign=top>:</td>
      <td valign=top> <input name="rek" type="text" id="rek" value='<?php echo $toko->rek?>'></td>
    </tr>
	
    <tr bordercolor="#FFFFFF"> 
      <td height="21" colspan="2"></td><td><font size="2" face="tahoma"> 
          <input type="submit" name="Submit42" value="Simpan">
		  <button type ="button" name="fulang2" value="Batal" class="btn btn-success" onClick="javascript:history.back()">Batal</button>
          </font>
        </td>
    </tr>
  </table>
</form>